<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<script src="indexjs/jquery.js" type="text/javascript"></script>
<script src="indexjs/encode.js" type="text/javascript"></script>
<title>网络接入认证系统</title>
<link href="indexcss/wm_7UI.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var time_out=1;//自动提交的等待时间，单位：秒
var call_me="请联系管理员。";//忘记密码、没有账号的对话框文本
var weburl="";//登录成功后打开的第1个通告页面，网站必须带http://
var save_time=120;//保存账号信息的时间，单位：小时

function cWH(){
var isMobile = !!navigator.userAgent.match(/AppleWebKit.*Mobile.*/) && !!navigator.userAgent.match(/AppleWebKit/);

var pageWidth = document.body.clientWidth > document.documentElement.clientWidth ? document.body.clientWidth : document.documentElement.clientWidth;
var mobileMaxWidth = 768, pcMaxWidth = 480, pcMinWidth = 320;	
var mainWidth = isMobile ? (pageWidth>mobileMaxWidth ? mobileMaxWidth : pageWidth) : (pageWidth>pcMaxWidth ? pcMaxWidth : (pageWidth<pcMinWidth ? pcMinWidth : pageWidth));	
$("#main").width(mainWidth-2-2);

var pageHeight = document.body.clientHeight > document.documentElement.clientHeight ? document.body.clientHeight : document.documentElement.clientHeight;
var mainTop = pageHeight-$("#main").height();
	mainTop = mainTop<0 ? 0 : mainTop;
	mainTop = parseInt(mainTop/2,10);
	mainTop = (isMobile && mainTop>10) ? 10 : mainTop;
$("#main").css("margin-top",mainTop+"px");	
}
function aC(_n,_v){
var str = _n + "=" + escape(_v);
if(save_time > 0){
	var date = new Date();
	var ms = save_time*3600*1000;
	date.setTime(date.getTime() + ms);
	str += "; expires=" + date.toGMTString();
}
document.cookie = str;
}
function gC(_n){
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
	var temp = arrStr[i].split("=");
	if(temp[0] == _n) return unescape(temp[1]);
}
return "";
}		
function dC(name){
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = name + "=a; expires=" + date.toGMTString();
}
document.onkeydown = function(event){
var event = event || window.event;
var obj = event.target || event.srcElement;
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if(obj != null && obj.tagName != null && obj.tagName.toLowerCase() == "input"){
	if(keyCode == 13)
		login();
}
}
var ld="";
var init=0;
$(function(){
init = 1;
cWH();
setInterval(cWH,200);

ld=get_ld();
var _v=gC("save");
if (_v){
	$("#usr").val(gC("usr"));
	$("#pwd").val(gC("pwd"));
	$("#save")[0].checked=true;
	_v=gC("auto");
	if (_v == "true" ){
		$("#auto")[0].checked=true;
		if (time_out>0)
			setTimeout(autologin,time_out*1000);
		else
			login();
	}else{
		time_out = -1;
	}
}
$("#usr").focus();
});
function autologin(){
if (time_out>=0)
	login();
}
function login(){
var usr=$("#usr").val();
var pwd=$("#pwd").val();
var str="ajaxUI_Login.action?usr="+usr+"&pwd="+pwd;
if ($("#save")[0].checked){
	aC("usr", usr);
	aC("pwd", pwd);
	aC("save", true);
	aC("auto", $("#auto")[0].checked);
}
var data_str=encodeToUTF8(str);
$.ajax({
	type: "GET",
	url: data_str,
	success: post_fun,
	error: null,
	timeout: 10000,
	dataType: "json",
	cache: false
});
}
function post_fun(result){
var url = "";
var msg = eval("("+result+")");
if(msg.ret==0){
	aC("ip", msg.i);
	url = msg.l;
	if(url.length <= 7)
		url = get_ld();
	if(msg.e == '0')
		url = "";	
	if(weburl=="")
		weburl="ok.html?u="+ $("#usr").val()+"&i="+msg.i+"&l="+url;
	window.location.replace(weburl);
}else{
	$("#usr").focus();
	alert(msg.msg);
}
}
function get_ld(){
var tmp = window.location.href.split("ld=");
return tmp.length==2 ? tmp[1] : "";
}
function val_edit(obj){
if(init>0)
	time_out=-1;
}
function save_ck(obj){
val_edit();
if(!obj.checked){
	$("#auto")[0].checked=false;
	dC("usr");
	dC("pwd");
	dC("save");
	dC("auto");
}
}
function auto_ck(obj){
val_edit();
if(obj.checked)
	$("#save")[0].checked=true;
}
function call(){
alert(call_me);
return false;
}
</script>
    
</head>

<body>
<div id="wrapper">
<div class="logo"></div>
     <div class="header">
	      <div class="title">OpenPortal网络接入认证系统</div>
		  <div class="column">
		       <div class="login">
		       <div class="login_left">
					<div><label>用户名：</label><input id="usr" type="text" name="textfield" class="text_1"/></div>
	                <div><label>密码：</label><input id="pwd" type="password" name="textfield" class="text_1"/></div>
		       </div>
			   <div class="login_right">
			     <input type="submit" onClick="login()" name="Submit" value="" class="submit01" />
			   </div>
			   <div class="clear"></div>
		  </div>
		  <p class="ckp">
		    <input type="checkbox" id="save" onClick="save_ck(this)" name="checkbox2" value="checkbox" />
		    记住密码
		    <input type="checkbox" id="auto" onClick="auto_ck(this);" name="checkbox" value="checkbox" /> 
	      自动登录</p>
		  <p class="ckp" style="margin-top:18px;">
		    <input type="submit"  onClick="call()"  name="Submit2" value="" class="submit_2" />
		  </p>
		  <p class="bq">技术支持：OpenPortalServer项目</p>
		  </div>
	 </div>
	 <div class="footer"><a href="#"><img src="images/banner.jpg" border="0" /></a></div>
</div>
</body>
</html>
